home *** CD-ROM | disk | FTP | other *** search
/ Elite European Models 1 / Elite European Models 1.iso / pc / elite.dxr / 00012.ls < prev    next >
Encoding:
Text File  |  1996-05-06  |  7.9 KB  |  265 lines

  1. global gImages, gDataPos, gImageCount, theFirstImage, gPictSprite, gCenterH, gCenterV, gCurrentPict, gStartFrame, gEndFrame, gSpriteWidth, gSpriteHeight, gDistance
  2.  
  3. on startMovie
  4.   set the colorDepth to 8
  5.   unLoad()
  6.   setGlobals()
  7.   set the itemDelimiter to ","
  8.   hideShow(1, 48, 1, 4)
  9. end
  10.  
  11. on preloadFirstImages
  12.   set theList to "01A,02A,03A,04A,05A,06A,07A,08A,09A,10A,11A,12A,13A,14A,15A,16A"
  13.   repeat with x = 1 to 16
  14.     set whichCast to the number of member item x of theList
  15.     if whichCast > 0 then
  16.       preLoadCast(whichCast)
  17.     end if
  18.   end repeat
  19. end
  20.  
  21. on setGlobals
  22.   clearGlobals()
  23.   set gPictSprite to 1
  24.   set gCenterH to 320
  25.   set gCenterV to 240
  26.   set gCurrentPict to 1
  27.   repeat with x = 2 to 48
  28.     set the cursor of sprite x to 0
  29.   end repeat
  30. end
  31.  
  32. on selectModel whichModel
  33.   if the timer < 20 then
  34.     exit
  35.   end if
  36.   set gCurrentPict to whichModel
  37.   set gStartFrame to label("Start " & gCurrentPict)
  38.   set gEndFrame to label("End " & gCurrentPict)
  39.   advanceFrame(0)
  40.   set the cursor of sprite 2 to 0
  41.   startTimer()
  42. end
  43.  
  44. on advanceFrame frameModifier
  45.   cursor(4)
  46.   set currentRelativeFrame to checkRange(the frame, gStartFrame, gEndFrame)
  47.   set newFrame to checkRangeWrap(currentRelativeFrame + frameModifier, gStartFrame, gEndFrame)
  48.   if frameModifier = 0 then
  49.     hideShow(1, 48, 0, 5)
  50.     repeat with x = 3 to 15
  51.       puppetSprite(x, 0)
  52.     end repeat
  53.     go("buttons")
  54.     repeat with x = 3 to 15
  55.       puppetSprite(x, 1)
  56.     end repeat
  57.   end if
  58.   set the type of sprite 1 to 0
  59.   updateStage()
  60.   go(newFrame)
  61.   if the type of sprite gPictSprite = 0 then
  62.     puppetSprite(gPictSprite, 0)
  63.     go(the frame)
  64.   end if
  65.   set gSpriteWidth to the width of cast the castNum of sprite gPictSprite / 2
  66.   set gSpriteHeight to the height of cast the castNum of sprite gPictSprite / 2
  67.   set gDistance to 20
  68.   set the cursor of sprite 3 to -1
  69.   hideShow(1, 9, 1, 5)
  70.   if frameModifier <> 0 then
  71.     preLoad(checkRangeWrap(newFrame - 1, gStartFrame, gEndFrame))
  72.   end if
  73.   preLoad(checkRangeWrap(newFrame + 1, gStartFrame, gEndFrame))
  74.   set gPICThModifier to 0
  75.   set gPICTvModifier to 0
  76.   cursor(0)
  77.   startTimer()
  78. end
  79.  
  80. on correctPalette
  81.   puppetPalette("System")
  82.   updateStage()
  83.   puppetPalette(0)
  84.   updateStage()
  85. end
  86.  
  87. on quickHide
  88.   if the timer < 20 then
  89.     exit
  90.   end if
  91.   set theList to []
  92.   repeat with x = 1 to 48
  93.     if the type of sprite x = 0 then
  94.       setAt(theList, x, 0)
  95.     else
  96.       setAt(theList, x, [the visible of sprite x, the puppet of sprite x, the locV of sprite x])
  97.     end if
  98.     puppetSprite(x, 1)
  99.     set the locV of sprite x to -500
  100.     set the visible of sprite x to 0
  101.   end repeat
  102.   updateStage()
  103.   set howLong to the timer + 20
  104.   repeat while (the timer < howLong) or the mouseUp
  105.     updateStage()
  106.   end repeat
  107.   repeat while the mouseDown
  108.     updateStage()
  109.   end repeat
  110.   updateStage()
  111.   repeat with x = 1 to 48
  112.     set theListItem to getAt(theList, x)
  113.     if listp(theListItem) then
  114.       set the visible of sprite x to getAt(theListItem, 1)
  115.       puppetSprite(x, getAt(theListItem, 2))
  116.       set the locV of sprite x to getAt(theListItem, 3)
  117.     end if
  118.   end repeat
  119.   updateStage()
  120.   startTimer()
  121. end
  122.  
  123. on hideShow startSprite, endSprite, theVisible, whichTransition
  124.   repeat with x = startSprite to endSprite
  125.     set the visible of sprite x to theVisible
  126.   end repeat
  127.   if theVisible = 0 then
  128.     repeat with x = startSprite to endSprite
  129.       if the puppet of sprite x = 0 then
  130.         set the locV of sprite x to -500
  131.       end if
  132.     end repeat
  133.   end if
  134.   puppetTransition(whichTransition, 1, 12)
  135.   updateStage()
  136. end
  137.  
  138. on moveSprites startSprite, endSprite, posOrNeg
  139.   repeat with x = startSprite to endSprite
  140.     set the locV of sprite x to posOrNeg * abs(the locV of sprite x)
  141.   end repeat
  142.   updateStage()
  143. end
  144.  
  145. on returnToMenu
  146.   hideShow(1, 48, 0, 5)
  147.   repeat with x = 1 to 48
  148.     puppetSprite(x, 1)
  149.     set the locV of sprite x to -500
  150.   end repeat
  151.   go(label("menu") + 1)
  152.   repeat with x = 1 to 48
  153.     puppetSprite(x, 0)
  154.     set the visible of sprite x to 1
  155.   end repeat
  156.   set the visible of sprite 1 to 0
  157.   go(the frame + 1)
  158.   cursor(0)
  159.   cursor(-1)
  160.   startTimer()
  161. end
  162.  
  163. on zoomSprite whichSprite, userClickLoc, centerH, centerV
  164.   if the type of sprite whichSprite = 0 then
  165.     exit
  166.   end if
  167.   set the stretch of sprite whichSprite to not (the stretch of sprite whichSprite)
  168.   if the stretch of sprite whichSprite = 1 then
  169.     go(the frame)
  170.   else
  171.     set centerLoc to point(centerH, centerV)
  172.     set zoomLoc to stripPoint(centerLoc - userClickLoc)
  173.     set spriteWidth to the width of cast the castNum of sprite gPictSprite / 2
  174.     set spriteHeight to the height of cast the castNum of sprite gPictSprite / 2
  175.     set newH to checkRange(centerH + value(item 1 of zoomLoc), 640 - spriteWidth, spriteWidth)
  176.     set newV to checkRange(centerV + value(item 2 of zoomLoc), the top of sprite 3 - spriteHeight, spriteHeight)
  177.     set the locH of sprite whichSprite to newH
  178.     set the locV of sprite whichSprite to newV
  179.   end if
  180.   updateStage()
  181. end
  182.  
  183. on stripPoint whichPoint
  184.   set whichPoint to string(whichPoint)
  185.   set firstChar to offset("(", whichPoint) + 1
  186.   set lastChar to the number of chars in whichPoint - 1
  187.   set whichPoint to char firstChar to lastChar of whichPoint
  188.   return whichPoint
  189. end
  190.  
  191. on checkRange originalNumber, minValue, maxValue
  192.   if originalNumber < minValue then
  193.     set originalNumber to minValue
  194.   else
  195.     if originalNumber > maxValue then
  196.       set originalNumber to maxValue
  197.     end if
  198.   end if
  199.   return originalNumber
  200. end
  201.  
  202. on checkRangeWrap originalNumber, minValue, maxValue
  203.   if originalNumber < minValue then
  204.     set originalNumber to maxValue - (minValue - originalNumber) + 1
  205.   else
  206.     if originalNumber > maxValue then
  207.       set originalNumber to minValue + (originalNumber - maxValue) - 1
  208.     end if
  209.   end if
  210.   return originalNumber
  211. end
  212.  
  213. on zoomPICT whichSprite, userClickLoc, centerH, centerV
  214.   if the type of sprite whichSprite = 0 then
  215.     exit
  216.   end if
  217.   set the stretch of sprite whichSprite to not (the stretch of sprite whichSprite)
  218.   if the stretch of sprite whichSprite = 1 then
  219.     set magnificationFactor to 2
  220.     set whichCast to the castNum of sprite whichSprite
  221.     set newHeight to the height of cast whichCast / (magnificationFactor * 2)
  222.     set newWidth to the width of cast whichCast / (magnificationFactor * 2)
  223.     spriteBox(whichSprite, centerH - newWidth, centerV - newHeight, centerH + newWidth, centerV + newHeight)
  224.   else
  225.     set centerLoc to point(centerH, centerV)
  226.     set zoomLoc to stripPoint(centerLoc - userClickLoc)
  227.     set the locH of sprite whichSprite to centerH + value(item 1 of zoomLoc)
  228.     set the locV of sprite whichSprite to centerV + value(item 2 of zoomLoc)
  229.   end if
  230.   updateStage()
  231. end
  232.  
  233. on zoomPICTtoCenterHV whichSprite, userClickLoc, centerH, centerV
  234.   if the type of sprite whichSprite = 0 then
  235.     exit
  236.   end if
  237.   set the stretch of sprite whichSprite to not (the stretch of sprite whichSprite)
  238.   set magnificationFactor to 2
  239.   if the stretch of sprite whichSprite = 1 then
  240.     set whichCast to the castNum of sprite whichSprite
  241.     set newHeight to the height of cast whichCast / (magnificationFactor * 2)
  242.     set newWidth to the width of cast whichCast / (magnificationFactor * 2)
  243.     spriteBox(whichSprite, centerH - newWidth, centerV - newHeight, centerH + newWidth, centerV + newHeight)
  244.   else
  245.     set centerLoc to point(centerH, centerV)
  246.     set zoomLoc to stripPoint(userClickLoc - centerLoc)
  247.     set the locH of sprite whichSprite to centerH - (value(item 1 of zoomLoc) * magnificationFactor)
  248.     set the locV of sprite whichSprite to centerV - (value(item 2 of zoomLoc) * magnificationFactor)
  249.   end if
  250.   updateStage()
  251. end
  252.  
  253. on getMagnificationFactor whichSprite, heightOrWidth
  254.   set whichCast to the castNum of sprite whichSprite
  255.   if heightOrWidth = 0 then
  256.     set castHeight to the height of cast whichCast
  257.     set spriteHeight to the height of cast whichCast
  258.     return 1.0 * castHeight / spriteHeight
  259.   else
  260.     set castWidth to the width of cast whichCast
  261.     set spriteWidth to the width of cast whichCast
  262.     return 1.0 * castWidth / spriteWidth
  263.   end if
  264. end
  265.